package org.cbg.control;

import org.cbg.bean.SearchOrderResultBean;
import org.cbg.frame.TrslationMainJframe;
import org.cbg.panel.TraslationMyMainCardJpanel;
import org.cbg.until.TraslationTableMygoodsUntil;
import org.come.action.FromServerAction;
import org.come.until.GsonUtil;

//TODO 藏宝阁我的货物查询类回调(客户端)
/**
 * 藏宝阁我的货物查询类回调
 * 
 * @author Administrator
 * 
 */
public class SearchMyGoodsResultControl implements FromServerAction {

    @Override
    public void controlMessFromServer(String mes, String type) {
        // TODO Auto-generated method stub
        TrslationMainJframe trslationMainJframe = TrslationMainJframe.getTrslationMainJframe();
        // 消息处理部分
        SearchOrderResultBean sa = GsonUtil.getGsonUtil().getgson().fromJson(mes, SearchOrderResultBean.class);

        /**
         * 我的藏宝阁之我的货物的结果处理
         */
        trslationMainJframe.setGoodsGeshuMax(0);
        for (int i = 0; i < sa.getRoleorders().size(); i++) {
            if (sa.getRoleorders().get(i).getStatus() == 3) {
                trslationMainJframe.setGoodsGeshuMax(trslationMainJframe.getGoodsGeshuMax() + 1);
            }
        }
        TraslationMyMainCardJpanel traslationMyMainCardJpanel = TrslationMainJframe.getTrslationMainJframe().getTrslationMainJpanel().getTranslationMainCardJpanel().getTraslationMyMainJpanel().getTraslationMyMainCardJpanel();
        trslationMainJframe.setGoodsGouxuangeshu(0);
        // 处理消息添加到界面
        TraslationTableMygoodsUntil.setTableModel(traslationMyMainCardJpanel.getTraslationMyMainMygoodsJpanel()
                .getjScrollPane(), sa.getRoleorders());
        // 最大页数
        traslationMyMainCardJpanel.getTraslationMyMainMygoodsJpanel()
                .setPage(sa.getTotal() == 0 ? 1 : sa.getTotal());
        // 跳转到搜索结果界面
        traslationMyMainCardJpanel.getCardLayout()
                .show(traslationMyMainCardJpanel, "mygoods");

    }
}
